package za.org.jcicada.katcp;

/**
 * StrategyDiff.java
 *
 * @author Simon Cross
 * @author Adrianna Pinska
 *
 * Created on October 30, 2008, 16:27
 */

import za.org.jcicada.katcp.ISamplingStrategy;
import za.org.jcicada.katcp.StrategyBase;

/**
 * A strategy that samples whenever the sensor value changes by more than a given amount.
 */
public class StrategyDiff
extends StrategyBase {

    /**
     * The type of the associated sensor.
     */
    protected ISensor.Type sensorType;

    /**
     * Constructs a StrategyDiff object.
     *
     * @param sensor  The sensor to sample.
     * @param params  The strategy parameters (one parameter describing the difference to sample at).
     */
    public StrategyDiff(ISensor sensor, String[] params) {
        super(ISamplingStrategy.Strategy.DIFF, params);
        if (params.length != 1) {
            throw new IllegalArgumentException("The 'diff' sampling strategy takes one parameter.");
        }
        sensorType = sensor.getType();
    }

}
